package org.example.springmybatisdemo.filter;


import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;


import java.io.IOException;

@Slf4j
@WebFilter("/*") // 开启filter:第一步在filter上加上@WebFilter配置过滤路径(/*拦截所有) 第二步在引导类(也就是启动类)上加@ServletComponentScan扫描
public class LoginCheckFilter implements Filter {
//    ctrl + o 快速生成重写犯法
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
        log.info("filter init");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
        log.info("filter destroy");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("filter doFilter");
        filterChain.doFilter(servletRequest,servletResponse);
        log.info("filter finished doFilter");
    }
}
